// 随机文档: https://github.com/nuysoft/Mock/wiki/Mock.Random

const delay = require('mocker-api/lib/delay')
const Mock = require('mockjs')
const login = require('./login')
const groups = require('./groups')

const log = console.log.bind(console)

const mockers = [
    login,
    groups,
]

let data = {}
const mergeMockers = () => {
    for (let i = 0; i < mockers.length; i++) {
        const m = mockers[i]
        const ks = Object.keys(m)
        for (let j = 0; j < ks.length; j++) {
            const k = ks[j]
            if (data[k] !== undefined) {
                log(`mock: ${k} is already exist!`)
            }
        }
        Object.assign(data, m)
    }
}

mergeMockers()
data = Mock.mock(data)

module.exports = delay(data, 0)
